/**
 * @description:
 * @author: qintao
 * @create: 2019-08-28 18:10
 **/
package com.guoranhao.business.service.impl;

import com.guoranhao.business.dao.EsSpuMapper;
import com.guoranhao.business.dao.ShoppingCartMapper;
import com.guoranhao.business.model.EsSpu;
import com.guoranhao.business.model.EsSpuExample;
import com.guoranhao.business.model.ShoppingCart;
import com.guoranhao.business.service.EsSpuService;
import com.guoranhao.business.vo.EsSpuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EsSpuServiceImpl extends BaseServiceImpl<EsSpu, EsSpuExample> implements EsSpuService {

    @Autowired
    private EsSpuMapper esSpuMapper;

    @Autowired
    private ShoppingCartMapper shoppingCartMapper;

    @Override
    public Integer getShoppingCartCount(String openId) {
        return esSpuMapper.getShoppingCartCount(openId);
    }

    @Override
    public List<EsSpuVo> getShoppingCartList(String openId) {
        return esSpuMapper.getShoppingCartList(openId);
    }

    @Override
    public Boolean addGoods(ShoppingCart shoppingCart) {
        // todo 购物车不能减成负数
        return shoppingCartMapper.addGoods(shoppingCart) > 1;
    }
}
